package com.ly.consumer.thread.threadCreatMethod;
//通过runnable方式实现多线程
//1.创建线程类
class MyRunnable implements Runnable{
    //构建线程执行体 也就是新开的业务逻辑
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("线程2："+i);
        }
    }
}
public class MyRunnableDemo {
    public static void main(String[] args) {
        //2.创建线程对象
        MyRunnable myRunnable = new MyRunnable();
        //通过thread创建线程对象
        Thread t1 = new Thread(myRunnable);
        //3.开启start方法
        t1.start();
        for (int i = 0; i < 10; i++) {
            System.out.println("线程1："+i);
        }
    }

}
